import sys
sys.path.append("../")

from services.DayKlineService import *
import datetime

klineService = DayKlineService()

startDay = (datetime.datetime.now() - datetime.timedelta(days=15)).strftime("%Y-%m-%d")
endDay = (datetime.datetime.now() - datetime.timedelta(days=5)).strftime("%Y-%m-%d")

data = klineService.getTenHasZhangtingByDate(startDay,endDay)
codes = []
#第一步过滤市值
for option in data:
    shizhi = round(float(option["flow_money"])/100000000,2)
    if shizhi > 30 and shizhi < 50:
        #第二步看涨跌
        daydata = klineService.getDataByDate(option["code"],startDay,endDay)
        if(len(daydata)) > 3:
            yesterdaytata = daydata[len(daydata)-2]
            todaydata = daydata[len(daydata)-1]
            if float(todaydata["close"]) > float(yesterdaytata["close"]):
                codes.append(option)
print(len(codes))

